package com.hmall.order.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hmall.order.mapper.OrderMapper;
import com.hmall.order.pojo.Order;
import com.hmall.order.pojo.TbOrderDetail;
import com.hmall.order.pojo.TbOrderLogistics;
import com.hmall.order.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class OrderService extends ServiceImpl<OrderMapper, Order> implements IOrderService {
    @Autowired
    OrderService orderService;
    @Autowired
    TbOrderDetailServiceImpl tbOrderDetailService;
    @Autowired
    TbOrderLogisticsServiceImpl tbOrderLogisticsService;
    @Override
    @Transactional
    public Long saves(Order or, TbOrderDetail td, TbOrderLogistics tb) {
         orderService.save(or);
        Long id = or.getId();
        td.setOrderId(id);
        tbOrderDetailService.saves(td);
        tb.setOrderId(id);
        tbOrderLogisticsService.saves(tb);
        return id;

    }
}
